package com.zys.event;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.zys.domain.Teacher;
import com.zys.service.TeacherService;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@RequiredArgsConstructor
@Component
public class TeacherListener {
    private final TeacherService teacherService;

    @EventListener
    public void teacherStatus(Teacher teacher) {
        teacherService.update(new LambdaUpdateWrapper<Teacher>()
                .set(Teacher::getStatus, teacher.getStatus())
                .eq(Teacher::getId, teacher.getId())
        );
    }
}
